﻿
function mysharetime(shareUrl, imgUrl, tTitle, tContent, appid, timestamp, nonceStr, signature, fn) {
    wx.config({
        debug: false,
        appId: appid,
        timestamp: timestamp,
        nonceStr: nonceStr,
        signature: signature,
        jsApiList: [
          'onMenuShareTimeline',
          'onMenuShareAppMessage',
         'hideMenuItems'
        ]
    });
    wx.ready(function () {
        //alert("wx.ready");
        //分享朋友圈

        wx.onMenuShareTimeline({
            title: tTitle,
            desc: tContent, // 分享描述
            link: shareUrl,
            imgUrl: imgUrl,
            trigger: function (res) {

            },
            success: function (res) {
                if (fn) { fn(0); }
            },
            cancel: function (res) {

            },
            fail: function (res) {

            }
        });
        //分享朋友
        wx.onMenuShareAppMessage({
            title: tTitle,
            desc: tContent,
            link: shareUrl,
            imgUrl: imgUrl,
            trigger: function (res) {

            },
            success: function (res) {
                if (fn) { fn(1);}
            },
            cancel: function (res) {

            },
            fail: function (res) {

            }
        });

        wx.hideMenuItems({
            menuList: ["menuItem:copyUrl", "menuItem:share:email", "menuItem:openWithQQBrowser", "menuItem:readMode", "menuItem:originPage", "menuItem:openWithSafari"] // 要隐藏的菜单项，只能隐藏“传播类”和“保护类”按钮，所有menu项见附录3
        });
    });
    //分享错误提示
    wx.error(function (res) {
        //alert(res.errMsg);
    });
}
